package org.finalministry.gui.menu;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.finalministry.gui.GuiMainActionListener;

public class GuiMainMenuCreator {

	private GuiMainActionListener guiMainActionListener;
	private JMenuBar menuBar;

	public GuiMainMenuCreator(GuiMainActionListener guiMainActionListener) {
		this.guiMainActionListener = guiMainActionListener;

		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (ClassNotFoundException ex) {
		} catch (InstantiationException ex) {
		} catch (IllegalAccessException ex) {
		} catch (UnsupportedLookAndFeelException ex) {
		}
		//
		// UIManager.put("MenuBar.background",
		// ColorSchema.getMenuBackgroundColor());
		// UIManager.put("Menu.background",
		// ColorSchema.getMenuBackgroundColor());
		// UIManager.put("MenuBar.borderColor",
		// ColorSchema.getMenuBackgroundColor());
		// UIManager.put("MenuItem.background",
		// ColorSchema.getMenuBackgroundColor());
		// UIManager.put("MenuItem.foreground", ColorSchema.getMenuColor());
		// UIManager.put("MenuBar.foreground", ColorSchema.getMenuColor());

		menuBar = new JMenuBar();

		addFileMenu(menuBar);
		addHelpMenu(menuBar);
	}

	private void addFileMenu(JMenuBar menuBar) {

		JMenu m = new JMenu("File");

		m.add(addMenuItem("New Congregation"));
		m.add(addMenuItem("Select Congregation"));
		m.addSeparator();
		m.add(addMenuItem("Import Data"));
		m.add(addMenuItem("Export Data"));
		m.addSeparator();
		m.add(addMenuItem("Print"));
		m.addSeparator();
		m.add(addMenuItem("Exit"));

		menuBar.add(m);
	}

	private void addHelpMenu(JMenuBar menuBar) {

		JMenu m = new JMenu("Help");

		m.add(addMenuItem("About"));
		m.add(addMenuItem("Version Info"));
		m.add(addMenuItem("Help"));

		menuBar.add(m);
	}

	private JMenuItem addMenuItem(String name) {
		JMenuItem exitItem = new JMenuItem(name);
		exitItem.addActionListener(guiMainActionListener);
		return exitItem;
	}

	public JMenuBar getMenuBar() {
		return menuBar;
	}
}